﻿using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using System;

namespace AspNetCoreHttpPipeline
{
    public class Startup
    {
        public void Configure(IApplicationBuilder app)
        {
            // Middleware A
            app.Use(async (context, next) =>
            {
                Console.WriteLine(value: "A in");
                await next();
                Console.WriteLine(value: "A out");
            });

            // Middleware B
            app.Use(async (context, next) =>
            {
                Console.WriteLine(value: "B in");
                await next();
                Console.WriteLine(value: "B out");
            });

            // Middleware C
            app.Run(async (context) =>
            {
                Console.WriteLine(value: "C in");
                await context.Response.WriteAsync(text: "terminal middle");
            });
        }
    }
}
